package com.fairisanddog.controller;

import com.alibaba.fastjson.JSON;

import com.fairisanddog.entity.Movie;
import com.fairisanddog.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/movie")
public class MovieController {

    @Autowired()
    @Qualifier("MovieServiceImpl")
    private MovieService movieService;

    @RequestMapping("/findAllMovies")
    @ResponseBody
    public String queryAllMovies(){

        List<Movie> movies = movieService.queryAllMovies();
       String moviesJson = JSON.toJSONString(movies);

        return moviesJson;
    }
}
